Display *dpy = GDK_SCREEN_XDISPLAY (screen);
XRRScreenResources *resources;
RROutput primary_output;
+ RROutput first_output = None;
int i;
GArray *monitors;
gboolean randr12_compat = FALSE;
XRRFreeOutputInfo (output);
}
+ if (resources->noutput > 0)
+ first_output = resources->outputs[0];
+
XRRFreeScreenResources (resources);
/* non RandR 1.2 X driver doesn't return any usable multihead data */
for (i = 0; i < screen_x11->n_monitors; ++i)
{
if (screen_x11->monitors[i].output == primary_output)
- screen_x11->primary_monitor = i;
+ {
+ screen_x11->primary_monitor = i;
+ break;
+ }
/* No RandR1.3+ available or no primary set, fall back to prefer LVDS as primary if present */
if (primary_output == None &&
g_ascii_strncasecmp (screen_x11->monitors[i].output_name, "LVDS", 4) == 0)
- screen_x11->primary_monitor = i;
+ {
+ screen_x11->primary_monitor = i;
+ break;
+ }
+
+ /* No primary specified and no LVDS found */
+ if (screen_x11->monitors[i].output == first_output)
+ screen_x11->primary_monitor = i;
}
return screen_x11->n_monitors > 0;